//
//  UIBarButtonItem+Extension.swift
//  Douyu_Swift
//
//  Created by Albert Zhu on 16/11/1.
//  Copyright © 2016年 Albert Zhu. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    convenience init(dy_createItemImage image: String, highlightedImage: String, size: CGSize = CGSize(width: 0, height: 0)) {
        let btn = UIButton(type: .custom)
        
        btn.setImage(UIImage(named: image), for: [])
        btn.setImage(UIImage(named: highlightedImage), for: .highlighted)
        
        if size == CGSize(width: 0, height: 0) {
            btn.sizeToFit()
        }else{
            btn.bounds.size = size
        }
        
        self.init(customView: btn)
    }
}
